/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ania2.gui;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author pawel
 */
public class GameRecordCellRenderer extends JLabel implements TableCellRenderer {

    public GameRecordCellRenderer() {
        super();
        setOpaque(true);
    }

    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        if (value == null) {
            setBackground(new Color(238, 238, 238));
        } else if (row % 2 == 0) {
            setBackground(new Color(255, 255, 255));
        } else {
            setBackground(new Color(252, 252, 236));
        }
        if (isSelected) {
            setBackground(new Color(184, 207, 229));
        }
        this.setHorizontalAlignment(CENTER);
        setText((value == null) ? "" : value.toString());
        return this;
    }
}
